package com.xiaoyu.chap2.OOM;

/**
 * Created by xiaoyu on 16/3/31.
 *
 * VM Args：-Xss128k
 *
 * 在单个线程中，无论是由于栈桢太大还是虚拟机栈容量太小，当内存无法分配时，虚拟机抛出的都是SOF异常
 */
public class JavaVMStackSOF {
    private int stackLength = 1;
    public void stackLeak(){
        stackLength++;
        stackLeak();
    }

    public static void main(String[] args) throws Throwable{
        JavaVMStackSOF oom = new JavaVMStackSOF();

        try {
            oom.stackLeak();
        }catch (Throwable e){
            System.out.println("stack length:"+oom.stackLength);
            throw e;
        }
    }
}
